﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;

namespace IdragonetEye
{
   public class Class_appset
    {

       public static void SetKey(string key,string keyval)
       {
           //读取程序集的配置文件
           string assemblyConfigFile = Assembly.GetEntryAssembly().Location;

           Configuration config = ConfigurationManager.OpenExeConfiguration(assemblyConfigFile);
           //获取appSettings节点
           AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");


           //删除name，然后添加新值
           appSettings.Settings.Remove(key);
           appSettings.Settings.Add(key, keyval);

           //保存配置文件
           config.Save();
       }


    }
}
